import axiosInstance from './axiosInstance';
import { envConfig } from '@/config/env';
import { mockDashboardStats } from '@/mocks/data';

// 模拟API延迟
const mockDelay = (ms: number = 500) => new Promise(resolve => setTimeout(resolve, ms));

/**
 * 获取仪表盘统计数据
 */
export const getDashboardStats = async (): Promise<typeof mockDashboardStats> => {
  if (envConfig.mockEnable) {
    await mockDelay();
    // 返回深拷贝的模拟数据，避免修改原始数据
    return JSON.parse(JSON.stringify(mockDashboardStats));
  }
  
  return axiosInstance.get('/dashboard/stats');
};
    